package com.momo.cloudspringserver.controller;

import com.momo.cloudspringserver.entity.SysUser;
import com.momo.cloudspringserver.feign.FeignService;
import com.momo.cloudspringserver.utils.JSONResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: momo-cloud
 * @description: TODO
 * @author: Jie Li
 * @create: 2019-07-16 17:10
 **/
@RestController
@RequestMapping(value = "/platform/", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
@Slf4j
public class UserController {
    @Autowired
    private FeignService feignService;

    @RequestMapping("/userInfo/v1")
    public JSONResult getUserInfo(@RequestBody SysUser sysUser, @RequestHeader(value = "Authorization", required = false) String authorization) {
        log.info("Authorization:{}",authorization);
        return JSONResult.ok(sysUser);
    }

    @RequestMapping("/feignTest/v1")
    public JSONResult feignTest() {
        SysUser sysUser = SysUser.builder().sysUserName("李杰").areaId(1L).build();
        //feign调用服务
        JSONResult jsonResult = feignService.getUserInfo(sysUser);
//        JSONResult jsonResult = feignService.getUserInfo();
        return jsonResult;
    }
}
